package com.example.demo.service;

import com.example.demo.dto.IndexImgDto;
import com.example.demo.dto.StatusDto;
import com.example.demo.mapper.IndexImgMapper;
import com.example.demo.model.Result;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class IndexImgService {
    private IndexImgMapper indexImgMapper;
    /**
     * 用户端查轮播图
     */
    public Result getIndexImgFronted(){
        return Result.buildSuccess(indexImgMapper.getIndexImgFronted());
    }

    /**
     * 用户端查轮播图
     * @return
     */
//    public Result getAllIndexImg(){
//        List<IndexImg> indexImgs = indexImgMapper.selectList(null);
//        return Result.buildSuccess(indexImgs);
//    }

    /**
     * 客户端查轮播图
     */
    public Result getAllIndexImgBackend(){
        return Result.buildSuccess(indexImgMapper.getAllIndexImg());
    }

    /**
     * 轮播图状态修改
     */
    public Result changeStatus(StatusDto statusDto){
        indexImgMapper.updateIndexImgStatus(statusDto);
        return Result.buildSuccess();
    }
    public Result getById(Integer id){
        return Result.buildSuccess(indexImgMapper.getById(id));
    }


    public Result deleteById(Integer id) {
        indexImgMapper.deleteById(id);
        return Result.buildSuccess();
    }

    public Result addIndexImg(IndexImgDto indexImgDto){
        indexImgMapper.addIndexImg(indexImgDto);
        return Result.buildSuccess();
    }
}